package com.hw.one.dam2.util;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;

import com.hw.one.ext.util.UserUtil;

/**
 * 不同用户显示不同站点功能类
 * <p>
 * Copyright 2017 汉威.智慧环保事业部
 * Created by 毛超然 on 2017/7/10 0009.
 */
public class UserSiteUtil {

    /**
     * 判断session中Department中siteType中是否含有siteType
     *
     * @param siteType
     * @return
     */


    public static Boolean userIsNotContainSiteTypes(String siteType) {
        Map<String, Object> departmentMap = UserUtil.getDepartment();

        if (null == departmentMap) {
            return false;
        }
        Object siteTypes = departmentMap.get("siteType");
        if (null == siteTypes) {
            return false;
        }
        String[] siteTypeStrs = siteTypes.toString().split(",");
        String[] siteTypeParam = siteType.toString().split(",");
        for (String type : siteTypeStrs) {
            for (String param : siteTypeParam) {
                if (type.equals(param)) {
                    return true;
                }
            }
        }
        return false;
    }
    
	/** 
	* @Title: convertSiteTypeToCode 
	* @Description: TODO() 
	* @param @param siteTypeStr
	* @param @return     
	* @return List<String>    返回类型 
	* @author songjundan
	* @throws 
	*/ 
	public synchronized static List<String> convertSiteTypeToCode(String siteTypeStr){
		
		/**
         * 国控点 nationalSite 省控点 provinceSite 市控站cityAirSite 小型站 smallAirSite 工业源 industrySite
         * 扬尘 raiseDustSite 油烟 lampblackSite 市建委扬尘数据raiseDustNewSite  喷漆房 sprayBoothSite 加油站     
         * gasStationSite 工业废水 waterPollutionSite 水质断面 waterSurfaceSite 所有标准站
         * allNationalSite 所有空气站 allAirSite 所有污染源 allPollutionSite 所有站点 allSite
         */
		
		String[] siteTypeArray = siteTypeStr.split(",");
		List<String> siteTypes = new ArrayList<String>();
		//当siteType=allSite
		String[] allSite = {"001","002","003","004","101","102","103","104","105","201"};
		//当siteType=allAirSite
	    String[] allAirSite = {"001","002","003","004"};
	  //当siteType=allPollutionSite
	  	String[] allPollutionSite = {"101","102","103","104","105","201"};
	  //当siteType=waterSurfaceSite
	  	String[] waterSurfaceSite = {"006","007","008","009","010","011"};
	  	String[] allNationalSite = {"001","002"};
		for(String siteType :siteTypeArray){
			if(siteType.equals("allSite")){
				Collections.addAll(siteTypes, allSite);
			}else if(siteType.equals("allAirSite")){
				Collections.addAll(siteTypes, allAirSite);
			}else if(siteType.equals("allPollutionSite")){
				Collections.addAll(siteTypes, allPollutionSite);
			}else if(siteType.equals("allNationalSite")){
				Collections.addAll(siteTypes, allNationalSite);
			}else if(siteType.equals("waterSurfaceSite")){
				Collections.addAll(siteTypes, waterSurfaceSite);
			}else if(siteType.equals("nationalSite")){
				siteTypes.add("001");
			}else if(siteType.equals("provinceSite")){
				siteTypes.add("002");
			}else if(siteType.equals("cityAirSite")){
				siteTypes.add("003");
			}else if(siteType.equals("smallAirSite")){
				siteTypes.add("004");
			}else if(siteType.equals("industrySite")){
				siteTypes.add("101");
			}else if(siteType.equals("raiseDustSite")){
				siteTypes.add("102");
			}else if(siteType.equals("lampblackSite")){
				siteTypes.add("103");
			}else if(siteType.equals("sprayBoothSite")){
				siteTypes.add("104");
			}else if(siteType.equals("gasStationSite")){
				siteTypes.add("105");
			}else if(siteType.equals("waterPollutionSite")){
				siteTypes.add("201");
			}else if(siteType.equals("raiseDustNewSite")){
				siteTypes.add("106");
			}else{
				continue;
			}
			
		}
	    	return siteTypes;
	    }
}
